<?php 
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include '../content-home/showscreen.php';
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">

.tbchung {background:white; cursor: default;}

.tbchung tr th {border-top:2px solid #828282;border-right:2px solid #828282; border-bottom:2px solid #828282;padding:4px;background:url(../images/bgth.png) repeat-x;}
.tbchung tr th.last {border-top:2px solid #828282;border-right:2px solid #828282; border-bottom:2px solid #828282;padding:4px; background:url(../images/bgth.png) repeat-x;}
.tbchung tr th.first {border-top:2px solid #828282;border-left:2px solid #828282;border-right:2px solid #828282; border-bottom:2px solid #828282;padding:4px; background:url(../images/bgth.png) repeat-x;}
.tbchung tr td {padding:4px; border-right:2px solid #828282}
.tbchung tr td.last {padding:4px;  border-right:2px solid #828282}
.tbchung tr td.first {padding:4px; border-left:2px solid #828282; border-right:2px solid #828282}
@media print {
	div.break {page-break-after:always}
}

</style>

<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("table tr:last td").each(function(){
		$(this).css('border-bottom','2px solid  #828282');
	});
	
});

</script>

<script type="text/javascript">
function OnSizeImage1(ele){
	var img = new Image();
	img.onload = function() {
		width = this.width;
		height = this.height;
		temp = (height/width);
		$(ele).attr('height', 910*temp);
	}
	img.src = $(ele).attr('src');
}

function OnSizeImage(ele){
	var img = new Image();
	img.onload = function() {
		width = this.width;
		height = this.height;
		temp = (height/width);
		$(ele).attr('height', 310*temp);
	}
	img.src = $(ele).attr('src');
}
</script>

</head>

<body style="background-color: #ffffff;text-align:center" onload="window.print()">
    
               <?php 
               $currentDate = date('Y-m-d h:m');
               $formatDate = "출력일: ".substr($currentDate, 0,4)."년".substr($currentDate, 5,2)."월".substr($currentDate, 8,2)."일 ".substr($currentDate, 11,2)."시".substr($currentDate, 14,2)."분";
               
               $index = 0;
               $mylist = $_SESSION['mylistcarnum'];
               if (isset($_SESSION['printview'])) {
               		$url = new showscreen();
	            	foreach ($_SESSION['printview'] as $key => $value) {
	            		$index+=1;
            			$row = $mylist[$key];
	                	//array($row[id],$row[name],$row[car_datetime],$row[carnumber],$row[host],$row[filename],$row[isReg]);
	               		$m_date = substr($row[2], 0,4)."년".substr($row[2], 5,2)."월".substr($row[2], 8,2)."일";
	               		$m_time = substr($row[2], 11,2)."시".substr($row[2], 14,2)."분".substr($row[2], 17,2)."초";
	               		
	               		$id = $row[0];
						$name = $row[1];
						$car_datetime = $row[2];
						$carnumber = $row[3];
						$host = $row[4];
						$filename1 = $row[5];
						$isReg = $row[6];
						
						$first = substr($filename1, 0,18);
						$middle = substr($filename1, 18,3);
						$last = substr($filename1, 21);
						$filename2 = $first.'002'.$last;
						$filename3 = $first.'002'.$last;
					
				        $url->GetPath($id,$name,$car_datetime,$carnumber,$host,$filename1,$isReg);
				        $url1 = $url->image;
				        $url->GetPath($id,$name,$car_datetime,$carnumber,$host,$filename2,$isReg);
				        $url2 = $url->image;
				        $url->GetPath($id,$name,$car_datetime,$carnumber,$host,$filename3,$isReg);
				        $url3 = $url->image;
				        
            			?>
            			<div style="width:950px;margin-top:40; margin-left:auto;margin-right:auto;text-align:center" classs="break">
	            			<div style="width:100%" align="right"><label><?=$formatDate?></label></div>
	            			<table cellpadding="0" cellspacing="0" border="0" width="950px" class="tbchung" style="border:none;margin-top:10; margin-left:auto;margin-right:auto;text-align:center" id="tableheader2">
					             <tr>
					               		<th width="10%" align="center" class="first">순서</th>
				                    	<th width="18%" align="center">날짜</th>
				                    	<th width="18%" align="center">시간</th>
				                    	<th width="10%" align="center" class="header">차로</th>
				                    	<th width="18%" align="center">차량번호</th>
				                    	<th width="26%" class="last" align="center">촬영 장소</th>   
	               				</tr>
	               				<tr class="trkhac" >
								 	<td  align="center" style="border-bottom:2px solid  #828282" class="first"><?=$index?></td>
							 	<td  align="center" style="border-bottom:2px solid  #828282"><?=$m_date?></td>
							 	<td  align="center" style="border-bottom:2px solid  #828282"><?=$m_time?></td>
							 	<td  align="center" style="border-bottom:2px solid  #828282">1</td>
							 	<td  align="center" style="border-bottom:2px solid  #828282" ><?=$row[3]?>&nbsp;</td>
							 	<td class="last" align="center" style="border-bottom:2px solid  #828282"><?=$row[1]?></td>
							</tr> 
							</table>
							<div style="width:910;margin-top:10; margin-left:auto;margin-right:auto;text-align:center">
								<img width="100%" height="auto" onload="OnSizeImage1(this)" src="<?=$url1?>" onerror="this.src='../images/noimage.jpg';">
							</div>
							<div style="width:100%;margin-top:10; margin-left:auto;margin-right:auto;text-align:center">
								<img width="33%" height="auto" onload="OnSizeImage(this)" src="<?=$url1?>" onerror="this.src='../images/noimage.jpg';">
								<img width="33%" height="auto" onload="OnSizeImage(this)" src="<?=$url2?>" onerror="this.src='../images/noimage.jpg';">
								<img width="33%" height="auto" onload="OnSizeImage(this)" src="<?=$url3?>" onerror="this.src='../images/noimage.jpg';">
							</div>
							<div class="break"></div>
            			</div>
						
	            	<?php 
	            		
               }
				unset($_SESSION['printview']);		               		
               }?>
              
	
</body>     
</html>